From : Ted Bailey (Ted@blitzuk.demon.co.uk)
Subject : AGA dual playfields
;
; Dual playfield display example for AGA Amigas only.
;
; Demonstrates how to get the correct colours for the rear
; playfield by using DisplayControls - see Page 137 of the new
; manual or press RightAmiga/Help on the same line as the command ;)
;
; Ted Bailey 12/2/96
;
;CloseEd:NoCli
SetErr:End:End SetErr
SpriteMode 2 ; AGA only sprites (64 pixels wide)
NEWTYPE.spr ; for the list of three AGA sprites
sx.w ; x position
xv.w ; x velocity
sy.w ; y "
yv.w ; y "
ch.w ; sprite channel to display sprite through
End NEWTYPE ;
Dim List sprites.spr(2)
BitMap 0,384,288,4 ; front playfield 16 colour bitmap
BitMap 1,384,288,4 ; back playfield 16 colour bitmap
InitShape 0,64,64,4 ; shape to turn into a sprite
ShapesBitMap 0,2 ; for drawing directly onto shapes 'bitmap'
InitPalette 0,256 ; colour regs 0 and 16 are transparent
; colour regs 1->15 are for front playfield
; colour regs 15->31 are for back playfield
; colour regs 240->255 are for sprites
; AGA dualplayfield, smoothscrolling display
InitCopList 0,40,256,$10038,8,256,0
; make the back playfield use colour registers 16->31
; by putting %0001110000000000 ($1c00) into BPLCON3
; and make the sprites use colour registers 240->255
; by putting %0000000011101110 ($00ee) into BPLCON4
DisplayControls 0,0,$1c00,$00ee
VWait 50:BLITZ
Gosub initcolours
Gosub initbitmaps
Gosub initsprites
d.w=0 ; initialise 'degrees' counter
fx.q=16 ; front playfield x starting position
fy.q=16 ; " " y " "
bx.q=16 ; back " x " "
by.q=16 ; " " y " "
CreateDisplay 0:DisplayPalette 0,0
Repeat
VWait
DisplayBitMap 0,0,fx,fy,1,bx,by
Gosub movesprites ; move/display 3 64*64 16 colour sprites
ang.f=d*Pi/180 ;
sinn=Sin(ang)*16 ; move front and back playfields
coss=Cos(ang)*16 ; in a circle pattern
;
fx=16+sinn ;
fy=16+coss ;
;
bx=16+coss ;
by=16+sinn ;
d+3:If d>359 Then d=0 ; increment degrees counter
Until Joyb(0)
End
.initcolours
;
For cr=1 To 15 ;
AGAPalRGB 0,cr,0,Rnd(255),50+cr*10 ; front playfield colours
Next ;
;
For cr=17 To 31 ;
AGAPalRGB 0,cr,50+cr*5,Rnd(255),0 ; back playfield colours
Next ;
;
For cr=240 To 255 ;
col=(255-cr)*15 ;
AGAPalRGB 0,cr,col,col,col ; sprite colours
Next ;
;
Return
.initbitmaps
;
Use BitMap 0 ; draw some random lines + circles on
For i.w=1 To 15 ; the front bitmap
For n.w=1 To 5
Line Rnd(384),Rnd(288),Rnd(384),Rnd(288),i
Circlef Rnd(384),Rnd(288),10+Rnd(10),10+Rnd(10),i
Next
Next
;
Use BitMap 1 ; draw some random circles on the back
For i=1 To 15 ; bitmap
For n=1 To 5
Circlef Rnd(384),Rnd(288),20+Rnd(10),20+Rnd(10),i
Next
Next
;
Return
.initsprites
;
Use BitMap 2 ; draw some concentric circles on the
For i=1 To 15 ; shapes' bitmap
Circlef 32,32,32-i*2,16-i
Next
GetaSprite 0,0 ; turn the shape into a sprite
Free Shape 0 ; get rid of shape
;
chn.w=0 ; initialise sprite channel counter
USEPATH sprites()
While AddItem(sprites())
\sx=50+Rnd(100) ;
\xv=1+Rnd(4) ; initialise each sprites' x/y positions
\sy=-50-Rnd(50) ; and velocities.
\yv=1 ;
\ch=chn ; set the sprite channel to display through
chn+2 ; needs 2 channels per sprite (16 colours)
Wend
;
Return
.movesprites
;
USEPATH sprites()
ResetList sprites()
While NextItem(sprites())
\sx+\xv ;
If \sx<0 Then \xv=-\xv:\sx=0 ; bounce off walls
If \sx>256 Then \xv=-\xv:\sx=256 ;
;
\yv+1 ;
\sy+\yv ; bounce off ground
If \sy>194 Then \yv=-10-Rnd(10):\sy=194 ;
;
DisplaySprite 0,0,\sx,\sy,\ch ; show the sprite
Wend
;
Return